import base_control from "@/lib/core/base_control.js"
import compile from "@/lib/core/render/compile.js";
function layout(args = undefined, context = undefined, compile_source_file = undefined) {
    this.constructor_template = {
        functional: true,
        name: "root",
        data: () => {
            return {
                vtext: "bbbbbbbbb",
                /*
                masterSelected: ["WS"],
                leftSelected:["Task"]*/
            };
        },
        methods: {
        },
        props: {
        },
        style: {
            "#components-layout-demo-top-side-2 .logo": {
                width: "120px",
                height: "31px",
                background: "rgba(255, 255, 255, 0.2)",
                margin: "16px 28px 16px 0",
                float: "left",
            }
        }
    };

    this.render_ops = undefined/*(args == undefined | args == null) ? {
        el: "#app",
        //parentEl:'tests',
        //mountType:"append",
        propsData: {
        }
    } : args;*/

    this.v_node = undefined
    if (compile_source_file != undefined) {
        compile.make(compile_source_file, context).asyncThen((data) => {
            console.log(data)
            this.v_node = data.nodes
            this.render_ops = data.layout.mount
            this.create_instance(data.data)
            if ('mount' in data.layout) {
                if ('func' in data.layout.mount) {
                    for (let o in data.layout.mount.func) {
                        this.constructor_template.methods[o] = function (event) {
                            let eventFunc = require('/public/scripts/'+ data.layout.mount.func[o]).default
                            let eventInstance = new eventFunc()
                            eval("eventInstance." + o + "(event, this)")
                        }
                    }
                }
            }
            this.build({ constructor: this.constructor_template, render: this.render_ops, vnode: this.v_node, compile_file: compile_source_file })
        })
    } else {
        this.build({ constructor: this.constructor_template, render: this.render_ops, vnode: this.v_node, compile_file: compile_source_file })
    }

}

layout.prototype = new base_control();
layout.prototype.constructor = layout;
export default layout